package fr.synchrone.starsudoku;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class StarSudoku extends Activity{
	private int level = 1;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button startNewGame = (Button)findViewById(R.id.startNewGameButton);
        startNewGame.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent();
				Bundle b = new Bundle();
				b.putInt("level", level);
				i.putExtras(b);
				i.setClass(StarSudoku.this, GameView.class);
	            startActivity(i);
			}
		});
        
        Button scoreBtn = (Button)findViewById(R.id.scoreButton);
        scoreBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent i = new Intent();
				i.setClass(StarSudoku.this, ScoreView.class);
	            startActivity(i);
			}
		});
        
        Button quitGame = (Button)findViewById(R.id.quitButton);
        quitGame.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				finish();
			}
		});
        RadioGroup group = (RadioGroup)findViewById(R.id.levelRadioGroup);
        group.setOnCheckedChangeListener(new OnCheckedChangeListener(){
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				switch(checkedId){
				case R.id.radioEasy:
					level = 1;
					break;
				case R.id.radioMedium:
					level = 50;
					break;
				case R.id.radioHard:
					level = 65;
					break;
				default :
					level = 1;
				}
			}
		});
    }
    
    @Override
    protected void onResume() {
    	// TODO Auto-generated method stub
    	super.onResume();
    }
}